<?php
class Cookie
{
	/**
	 * Construct cookie
	 *
	 * Accepts four parameter, or you can submit an associative
	 * array in the first parameter containing all the values.
	 *
	 * @access	public
	 * @param	string	the number of seconds until expiration
	 * @param	string	the cookie domain.  Usually:  .yourdomain.com
	 * @param	string	the cookie path
	 * @param	string	the cookie prefix
	 * @return	void
	 */
	function  __construct($expire = '', $path = '/', $domain = '', $prefix = '')
	{
		$this->domain	= $domain ;
		$this->path		= $path;
		$this->prefix	= $prefix;
		if ( ! is_numeric($expire)) {
			$this->expire = time() - 86500;
		} else {
			if ($expire > 0) {
				$this->expire = time() + $expire;
			} else {
				$this->expire = 0;
			}
		}	
	}
	/**
	 * Set cookie
	 *
	 * Accepts six parameter, or you can submit an associative
	 * array in the first parameter containing all the values.
	 *
	 * @access	public
	 * @param	string	the name of the cookie
	 * @param	string	the value of the cookie
	 * @return	void
	 */
	function set($name = '', $value = '')
	{
		setcookie($this->prefix.$name, $value, $this->expire, $this->path, $this->domain, 0);
	}


	/**
	 * Fetch an item from the COOKIE array
	 *
	 * @access	public
	 * @param	string
	 * @return	mixed
	 */

	function get($index = '')
	{
		return $_COOKIE[$index];
	}

	/**
	 * Delete a COOKIE
	 *
	 * @param	string
	 * @return	void
	 */
	function del($name = '')
	{
		setcookie($this->prefix.$name, '', time() - 86500, $this->path, $this->domain);
	}

}